package com.example.user1.controller;

import com.example.user1.cmd.LoginCmd;
import com.example.user1.service.UserService;
import com.example.user1.vo.LoginVo;
import com.example.user1.vo.Result;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("user")
@RequiredArgsConstructor
public class UserLoginController {

    private final UserService userService;
    @PostMapping("/login")
    @ResponseBody
    public Result<LoginVo> login(@Valid LoginCmd cmd){
        return userService.login(cmd);
    }

    @GetMapping("/refreshToken/{id}")
    @ResponseBody
    public Result<String> refreshToken(@PathVariable("id") Long id){
        return userService.refreshToken(id);
    }
}

